#pragma once
#include "Comm.h"

namespace COMM
{
	typedef struct 
	{
		unsigned short year;
		unsigned short month;
		unsigned short day;
		unsigned short wday; // day of week.
		unsigned short hour;
		unsigned short minute;
		unsigned short second;
		unsigned int microsecond;
	}CommTime;

	class COMM_API Timer
	{
	public:
		static CommTime Now();
#ifndef COMM_MSVC
		static timespec MakeTimespec(unsigned int timeoutMs);
#endif

		Timer(bool startup = false);
		void Start();
		void Stop();
		// unit: microsecond.
		long long Elapse();
	private:
		long long m_time[3]; 
	};

	class COMM_API TimeCounter
	{
	public:
		TimeCounter(Timer* timer);
		~TimeCounter();
	private:
		Timer* m_timer;
	};
}


